#pragma once
#include "stdafx.h"
#include "FbxCache.h"
#include "FbxObject.h"
#include "FbxString.h"
#include "FbxTime.h"
#include "FbxError.h"
#include "FbxClassId.h"
#include "FbxSdkManager.h"


namespace Skill
{
	namespace FbxSDK
	{				
		void FbxCache::CollectManagedMemory()
		{
			_KError = nullptr;
			FbxObject::CollectManagedMemory();
		}
		FBXOBJECT_DEFINITION(FbxCache,KFbxCache);

		FbxCache::FileFormat FbxCache::CacheFileFormat::get()
		{
			return (FileFormat)_Ref()->GetCacheFileFormat();
		}
		void FbxCache::CacheFileFormat::set(FileFormat value)
		{
			_Ref()->SetCacheFileFormat((KFbxCache::EFileFormat)value);
		}			
		void FbxCache::SetCacheFileName(System::String^ relativeFileName, System::String^ absoluteFileName)
		{
			STRINGTO_CONSTCHAR_ANSI(r,relativeFileName);
			STRINGTO_CONSTCHAR_ANSI(a,absoluteFileName);
			_Ref()->SetCacheFileName(r,a);
			FREECHARPOINTER(r);
			FREECHARPOINTER(a);
		}
		void FbxCache::GetCacheFileName([OutAttribute]String^ %relativeFileName, [OutAttribute]String^ %absoluteFileName)
		{
			KString r;
			KString a;
			_Ref()->GetCacheFileName(r,a);

			CONVERT_KSTRING_TO_STRING(r,rStr);
			CONVERT_KSTRING_TO_STRING(a,aStr);

			relativeFileName = rStr;
			absoluteFileName = aStr;
		}
		bool FbxCache::OpenFileForRead()
		{
			return _Ref()->OpenFileForRead();
		}
		bool FbxCache::IsOpen::get()
		{
			return _Ref()->IsOpen();
		}			
		bool FbxCache::CloseFile()
		{
			return _Ref()->CloseFile();
		}
		double FbxCache::SamplingFrameRate::get()
		{
			return _Ref()->GetSamplingFrameRate();
		}			
		FbxTime^ FbxCache::CacheTimePerFrame::get()
		{
			return gcnew FbxTime(_Ref()->GetCacheTimePerFrame());
		}					
		bool FbxCache::OpenFileForWrite(MCFileCount fileCount, double samplingFrameRate, System::String^ channelName, MCDataType CDataType)
		{
			STRINGTO_CONSTCHAR_ANSI(ch,channelName);			
			bool b = _Ref()->OpenFileForWrite((KFbxCache::EMCFileCount)fileCount,samplingFrameRate, ch, (KFbxCache::EMCDataType)CDataType);
			FREECHARPOINTER(ch);
			return b;
		}
		bool FbxCache::OpenFileForWrite(MCFileCount fileCount, double samplingFrameRate, System::String^ channelName)
		{
			STRINGTO_CONSTCHAR_ANSI(ch,channelName);			
			bool b = _Ref()->OpenFileForWrite((KFbxCache::EMCFileCount)fileCount,samplingFrameRate, ch);
			FREECHARPOINTER(ch);
			return b;
		}
		int  FbxCache::ChannelCount::get()
		{
			return _Ref()->GetChannelCount();
		}			
		bool FbxCache::GetChannelName(int channelIndex, [OutAttribute]String^ %channelName)
		{
			KString k;
			bool b = _Ref()->GetChannelName(channelIndex,k);
			CONVERT_KSTRING_TO_STRING(k,str);
			channelName = str;
			return b;
		}
		bool FbxCache::GetChannelDataType(int channelIndex, MCDataType %channelType)			
		{
			bool b = false;
			KFbxCache::EMCDataType d;
			b = _Ref()->GetChannelDataType(channelIndex,d);
			if(b)				
				channelType =(MCDataType)d;
			return b;
		}
		int FbxCache::GetChannelIndex(System::String^ channelName)
		{
			STRINGTO_CONSTCHAR_ANSI(ch,channelName);
			int i = _Ref()->GetChannelIndex(ch);
			FREECHARPOINTER(ch);
			return i;
		}
		bool FbxCache::GetAnimationRange(int channelIndex, FbxTime^ timeStart, FbxTime^ timeEnd)
		{
			return _Ref()->GetAnimationRange(channelIndex,*timeStart->_Ref(),*timeEnd->_Ref());
		}
		bool FbxCache::GetCacheType(MCFileCount %fileCount)
		{
			bool b;
			KFbxCache::EMCFileCount c;
			b = _Ref()->GetCacheType(c);
			if(b)
				fileCount = (MCFileCount)c;
			return b;
		}
		bool FbxCache::GetChannelInterpretation(int channelIndex, [OutAttribute]String^ %interpretation)
		{
			KString k;
			bool b = _Ref()->GetChannelInterpretation(channelIndex,k);
			CONVERT_KSTRING_TO_STRING(k,str);
			interpretation = str;
			return b;
		}			
		bool FbxCache::GetChannelSamplingType(int channelIndex, FbxCache::MCSamplingType %samplingType)
		{
			bool b;
			KFbxCache::EMCSamplingType c;
			b = _Ref()->GetChannelSamplingType(channelIndex, c);
			if(b)
				samplingType = (MCSamplingType)c;
			return b;
		}
		bool FbxCache::GetChannelSamplingRate(int channelIndex, FbxTime^ samplingRate)
		{
			return _Ref()->GetChannelSamplingRate(channelIndex,*samplingRate->_Ref());
		}
		bool FbxCache::GetChannelSampleCount(int channelIndex, unsigned int %sampleCount)
		{
			bool b;
			unsigned int i;
			b = _Ref()->GetChannelSampleCount(channelIndex, i);
			sampleCount = i;
			return b;
		}
		bool FbxCache::GetChannelPointCount(int channelIndex, FbxTime^ time, unsigned int %pointCount)
		{
			bool b;
			unsigned int i;
			b = _Ref()->GetChannelPointCount(channelIndex,*time->_Ref(),i);
			pointCount = i;
			return b;
		}
		int  FbxCache::CacheDataFileCount::get()
		{
			return _Ref()->GetCacheDataFileCount();
		}			
		bool FbxCache::GetCacheDataFileName(int index, FbxString^ %relativeFileName, FbxString^ %absoluteFileName)
		{
			return _Ref()->GetCacheDataFileName(index,*relativeFileName->_Ref(),*absoluteFileName->_Ref());
		}
		bool FbxCache::EnableMultiChannelFetching(bool multiChannelFetching)
		{
			return _Ref()->EnableMultiChannelFetching(multiChannelFetching);
		}
		bool FbxCache::OpenFileForWrite(double frameStartOffset, double samplingFrameRate, unsigned int sampleCount, unsigned int pointCount)
		{
			return _Ref()->OpenFileForWrite(frameStartOffset,samplingFrameRate,sampleCount,pointCount);

		}
		unsigned int FbxCache::SampleCount::get()
		{
			return _Ref()->GetSampleCount();
		}			
		unsigned int FbxCache::PointCount::get()
		{
			return _Ref()->GetPointCount();
		}			
		double FbxCache::FrameStartOffset::get()
		{
			return _Ref()->GetFrameStartOffset();
		}
		bool FbxCache::ConvertFromPC2ToMC(MCFileCount fileCount, double samplingFrameRate)
		{
			return  _Ref()->ConvertFromPC2ToMC((KFbxCache::EMCFileCount)fileCount,samplingFrameRate);
		}
		bool FbxCache::ConvertFromMCToPC2(double samplingFrameRate, unsigned int channelIndex)
		{
			return  _Ref()->ConvertFromMCToPC2(samplingFrameRate,channelIndex);
		}
		REF_PROPERTY_GET_DEFINATION_FROM_VALUE(FbxCache,GetError(),FbxError,KError);

		FbxCache::Error FbxCache::LastErrorID::get()
		{
			return (Error)_Ref()->GetLastErrorID();
		}
		System::String^ FbxCache::LastErrorString::get()
		{
			return gcnew System::String(_Ref()->GetLastErrorString());
		}

		/*System::String^ FbxCache::CacheFilePropertyName::get()
		{			
		cacheFilePropertyName = gcnew System::String(KFbxCache::CacheFilePropertyName);
		return cacheFilePropertyName;
		}

		System::String^ FbxCache::CacheFileAbsolutePathPropertyName::get()
		{
		if(cacheFileAbsolutePathPropertyName == nullptr)
		cacheFileAbsolutePathPropertyName = gcnew System::String(KFbxCache::CacheFileAbsolutePathPropertyName);
		return cacheFileAbsolutePathPropertyName;
		}		
		System::String^ FbxCache::CacheFileTypePropertyName::get()
		{
		if(cacheFileTypePropertyName == nullptr)
		cacheFileTypePropertyName = gcnew System::String(KFbxCache::CacheFileTypePropertyName);
		return cacheFileTypePropertyName;
		}*/
#ifndef DOXYGEN_SHOULD_SKIP_THIS
		CLONE_DEFINITION(FbxCache,KFbxCache);
#endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
	}
}